<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title>Simulations for Statistical and Thermal Physics</title>

<link href="../../default.css" type="text/css" rel="stylesheet">

</head>

<body>

<h3 style="text-align:center;">Demon simulation of the ideal gas</h3>

<p class="header_title">Introduction</p>

<p class = "inline">Consider an extra degree of
freedom called the <i>demon</i> that interacts with a system consisting of an ideal gas of particles. Because the gas is ideal, the only relevant coordinates are the velocities of the particles. The demon exchanges energy with the particles in the gas by choosing a particle at random and making a random change in its velocity. If the energy change of the system (the gas) is positive, the "extra" energy is given to the demon and the trial change is accepted. If the energy change of the gas is negative, the trial change is accepted if the demon has sufficient energy to give to the gas. The only constraint is that E<sub>d</sub>, the energy of the demon, must be greater than or equal to zero.</p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;The total energy of the demon plus
the system is fixed. The demon can exchange energy with the system as long as
the demon's energy remains greater than or equal to zero. The demon is a facilitator and allows the particles in the system to indirectly
exchange energy with one another even if they do not interact.</p>

<center>
<applet
 code="org.opensourcephysics.davidson.applets.ApplicationApplet.class"
 archive="./stp.jar" codebase="../" align="top" height="40"
 hspace="0" vspace="0" width="150"> <param name="target"
 value="org.opensourcephysics.stp.demon.DemonApp"> <param name="title"
 value="Applet"> <param name="singleapp" value="true">
</applet>
</center>

<p class="header_title">Algorithm</p>

<ol>

<li>Set up an initial microstate with the desired total energy
and assign an initial energy to the demon. For simplicity, we will choose the initial
demon
energy to be zero. We also initially assign each particle the same initial
velocity v in the x-direction, which is chosen so that the initial energy of the system is E. The initial velocity in the other directions for dimensions greater than one is set equal to zero.</li>

<li>Make a trial change in the microstate. For the ideal gas 
we choose a particle at random and increase or decrease its
velocity by (2r - 1)&#948;, where 0 &lt; r &#8804; 1 and r is generated at random. We then compute the change in the
energy of the system,
&#916;E.</li>

<li>If &#916;E &#8804; 0, we accept the change, and give the energy
-&#916;E to the demon so that the total energy of the system plus the
demon is constant. If &#916; E &gt; 0, we accept the change if the demon has
enough energy to give to the system, and reduce the demon's energy
by &#916;E. If the trial change is not accepted, the existing
microstate is counted in the averages.</li>

<li>Repeat steps 2 and 3 many times.</li>

<li>Compute the averages of the quantities of interest once
the system and the demon have reached equilibrium.</li>

</ol>

<p class="header_title">Problems</p>

<ol>

<li>Run the simulation using the default parameters. Does the average energy of the demon approach a well-defined value after a sufficient number of exchanges with the system? One Monte Carlo step per particle (mcs) is equivalent to N trial changes, where N is the number of particles in the system.</li>

<li>What is &lt;E<sub>d</sub>&gt;, the mean energy of the demon, and &lt;E&gt;, the mean energy of the system? Compare the values of &lt;E<sub>d</sub>&gt; and &lt;E&gt;/N, the mean energy per particle of the system.</li>

<li>Fix N and increase the total energy of the system. (The initial energy of the demon is zero.) Compare the values of &lt;E<sub>d</sub>&gt; and &lt;E&gt;/N. Does the ratio change?</li>

<li>What is the mean energy of an ideal gas in one dimension in terms of its temperature T?</li>

<li>In what ways does the demon act like an ideal thermometer? Why should we expect the demon to act like a system (of one particle) in equilibrium with a heat bath? In what sense is the ideal gas in this case a heat bath if N is sufficiently large? Discuss why the energy of the demon characterizes its microstate.</li>

<li>We know that the probability that a system in equilibrium with a heat bath at temperature T is in microstate s with energy E<sub>s</sub> is the Boltzmann
distribution:
<p class="center">
P<sub>s</sub>(E<sub>s</sub>) &#8733; exp(-E<sub>s</sub>/kT).
</p>
Given this form of P(E<sub>s</sub>), what is the probability that the energy of the demon is between E<sub>d</sub> and E<sub>d</sub> + &#916;E<sub>d</sub>?
Calculate the mean value of E<sub>d</sub> in terms of T.</li>

<li>Run for a sufficient number of trials so that the form of P(E<sub>d</sub>) is well defined. Choose <tt>Log Scale</tt> option under the <tt>Views</tt> menu to verify the exponential form of P(E<sub>d</sub>). Estimate T from the inverse slope of ln P(E<sub>d</sub>) versus E<sub>d</sub>. (The units are such that the Boltzmann constant k = 1.)</li>

<li>Explain your results for &lt;E<sub>d</sub>&gt; and &lt;E&gt;/N.</li> 

<li>What is the initial net velocity of the system in the x-direction? What is the net velocity of the system in the x-direction after equilibrium has been established? What is the  form of the velocity distribution after many energy exchanges? Explain your result in terms of the central limit theorem.</li>

<li>Repeat your simulations for two and three dimensions. Which results change and which results do not?</li>

<li>Consider a generalized ideal gas for which 
the energy per particle is proportional to p<sup>&#945;</sup>, where p is the momentum and &#945; is an exponent. For a classical particle 
&#945; = 2 and for a strongly relativistic particle &#945; = 1. Is there a simple relation between &lt;E<sub>d</sub>&gt; and &lt;E&gt;/N for &#945; = 1?</li>

</ol>

<p class="header_title">Java Classes</p>

<ul>

<li>DemonApp</li>
</ul>

<p class = "small">Updated 2 March 2007.</p>
</body>
</html>